// Fill out your copyright notice in the Description page of Project Settings.


#include "TickTestActor.h"
#include "TimerManager.h"

// Sets default values
ATickTestActor::ATickTestActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	TickableObject = MakeShareable(new FTickableTest);
	TickableObject->TickableCounter = Counter = 0;
}

// Called when the game starts or when spawned
void ATickTestActor::BeginPlay()
{	
	Super::BeginPlay();
	TickableObject->bTickable = true;
	GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ATickTestActor::TimerTick, 0.1f,	true);
}

// Called every frame
void ATickTestActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	//UE_LOG(LogTemp, Log, TEXT(__FUNCTION__"@%u %d"), __LINE__, Counter);
	++Counter;
	if (ensure(TickableObject))
	{
		TickableObject->TickableCounter = Counter;
	}

}

void ATickTestActor::TimerTick()
{
	//UE_LOG(LogTemp, Log, TEXT(__FUNCTION__"@%u %d"), __LINE__, Counter);
}

void FTickableTest::Tick(float DeltaTime)
{
	//UE_LOG(LogTemp, Log, TEXT(__FUNCTION__"@%u %d"), __LINE__, TickableCounter);
}
